﻿CREATE TABLE [dbo].[user_Referals] (
    [UserId]        UNIQUEIDENTIFIER NOT NULL,
    [ReferalUserId] UNIQUEIDENTIFIER NOT NULL,
    [TextId]        BIGINT           NOT NULL,
    CONSTRAINT [FK_user_Referals_text_Text] FOREIGN KEY ([TextId]) REFERENCES [dbo].[text_Text] ([TextId]),
    CONSTRAINT [FK_user_Referals_user_User] FOREIGN KEY ([ReferalUserId]) REFERENCES [dbo].[user_User] ([UserId])
);


GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_user_Referals_UserId_TextId]
    ON [dbo].[user_Referals]([UserId] ASC, [TextId] ASC);


GO

CREATE CLUSTERED INDEX [IX_user_Referals_UserId] ON [dbo].[user_Referals] ([UserId])
